package edu.yctc.patterns.builder;

import java.util.Date;

/**
 * @className MyUserDO
 * @description 自己定义实例化方式的UserDO
 * @author zyj
 * @date 2019年12月15日
 *
 */
public class MyUserDO {

    private final long id;

    /** 用户标识, 见{@link edu.yctc.patterns.constant.entity.tag.UserTag} */
    private final int tag;

    private final String account;

    private final String password;

    private final Date createTime;

    private final Date modifyTime;

    private MyUserDO(long id, int tag, String account, String password, Date createTime, Date modifyTime) {
        super();
        this.id = id;
        this.tag = tag;
        this.account = account;
        this.password = password;
        this.createTime = createTime;
        this.modifyTime = modifyTime;
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("MyUserDO [id=");
        builder.append(id);
        builder.append(", tag=");
        builder.append(tag);
        builder.append(", account=");
        builder.append(account);
        builder.append(", password=");
        builder.append(password);
        builder.append("]");
        return builder.toString();
    }

    public static MyUserDOBuilder builder() {
        return new MyUserDOBuilder();
    }

    public static class MyUserDOBuilder {
        private long id;

        /** 用户标识, 见{@link edu.yctc.patterns.constant.entity.tag.UserTag} */
        private int tag;

        private String account;

        private String password;

        private Date createTime;

        private Date modifyTime;

        public MyUserDOBuilder id(long id) {
            this.id = id;
            return this;
        }

        public MyUserDOBuilder tag(int tag) {
            this.tag = tag;
            return this;
        }

        public MyUserDOBuilder account(String account) {
            this.account = account;
            return this;
        }

        public MyUserDOBuilder password(String password) {
            this.password = password;
            return this;
        }

        public MyUserDOBuilder createTime(Date createTime) {
            this.createTime = createTime;
            return this;
        }

        public MyUserDOBuilder modifyTime(Date modifyTime) {
            this.modifyTime = modifyTime;
            return this;
        }

        public MyUserDO builde() {
            return new MyUserDO(id, tag, account, password, createTime, modifyTime);
        }

    }

}
